package com.lb.shopguide.ui.view.toast;

import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;

import com.lb.shopguide.R;

/**
 * Created by kang on 2018/3/12.
 */

public class ToastBossNoNet extends Toast {
    public static ToastBossNoNet mToastBoss;
    private Toast toast;

    public ToastBossNoNet(Context context) {
        super(context);
    }

    public static ToastBossNoNet getToastBossNoNet(Context context) {
        if (mToastBoss == null) {
            mToastBoss = new ToastBossNoNet(context);
        }
        return mToastBoss;
    }

    /**
     * 显示
     */
    public void toastShow(Context context) {
        View view = LayoutInflater.from(context).inflate(R.layout.layout_toast_no_network, null);
        toast = new Toast(context);
        toast.setGravity(Gravity.CENTER, 0, 0); // Toast显示的位置
        toast.setDuration(Toast.LENGTH_LONG); // Toast显示的时间
        toast.setView(view);
        toast.show();
    }

    public void toastCancel() {
        if (toast != null) {
            toast.cancel();
        }
    }
}
